HAL IRDA constants migration

This section provides information about the HAL IRDA constants migration.

Important

In HAL2, the IRDA driver is removed, and IRDA functionalities are integrated within the HAL UART driver.

HAL IRDA error codes constants

HAL1

HAL2

In HAL1, error handling is implemented through a collection of macros representing various error states.

Certain errors like HAL_IRDA_ERROR_NONE and HAL_IRDA_ERROR_DMA, are used for both receive (RX) and transmit (TX) operations.

In HAL2, the error definitions have been reorganized and renamed to enable more precise handling of receive and transmit operations.

  • The HAL_IRDA_ERROR_NONE and HAL_IRDA_ERROR_DMA have been split into separate transmit and receive error defines.

  • The HAL_IRDA_ERROR_INVALID_CALLBACK has been removed.

For more details refer to: HAL IRDA get error.

#define HAL_IRDA_ERROR_NONE
#define HAL_UART_RECEIVE_ERROR_NONE
#define HAL_UART_TRANSMIT_ERROR_NONE
#define HAL_IRDA_ERROR_PE
#define HAL_IRDA_ERROR_NE
#define HAL_IRDA_ERROR_FE
#define HAL_IRDA_ERROR_ORE
#define HAL_UART_RECEIVE_ERROR_PE
#define HAL_UART_RECEIVE_ERROR_NE
#define HAL_UART_RECEIVE_ERROR_FE
#define HAL_UART_RECEIVE_ERROR_ORE
#define HAL_IRDA_ERROR_DMA
#define HAL_UART_RECEIVE_ERROR_DMA
#define HAL_UART_TRANSMIT_ERROR_DMA
#define HAL_IRDA_ERROR_INVALID_CALLBACK

Removed

Related concepts: Revised and optimized HAL error management


HAL IRDA peripheral states constants

HAL1

HAL2

In HAL1, IRDA states are defined using macros, where each state is defined as a macro with a specific name.

In HAL2, the IRDA protocol utilizes the same state machine as UART, managed via three distinct state machines:

  • Global state machine: hal_uart_state_t

  • Reception state machine: hal_uart_rx_state_t

  • Transmission state machine: hal_uart_tx_state_t

#define HAL_IRDA_STATE_BUSY
#define HAL_IRDA_STATE_BUSY_RX
#define HAL_IRDA_STATE_BUSY_TX
#define HAL_IRDA_STATE_BUSY_TX_RX
#define HAL_IRDA_STATE_ERROR
#define HAL_IRDA_STATE_READY
#define HAL_IRDA_STATE_RESET
#define HAL_IRDA_STATE_TIMEOUT
typedef enum
{
  HAL_UART_STATE_RESET,
  HAL_UART_STATE_INIT,
  HAL_UART_STATE_CONFIGURED
} hal_uart_state_t;
typedef enum
{
  HAL_UART_RX_STATE_RESET,
  HAL_UART_RX_STATE_IDLE,
  HAL_UART_RX_STATE_ACTIVE,
  HAL_UART_RX_STATE_ABORT
} hal_uart_rx_state_t;
typedef enum
{
  HAL_UART_TX_STATE_RESET,
  HAL_UART_TX_STATE_IDLE,
  HAL_UART_TX_STATE_ACTIVE,
  HAL_UART_TX_STATE_ABORT
} hal_uart_tx_state_t;

Related concepts: Revised and optimized HAL state machine


HAL IRDA power mode settings constants

HAL1

HAL2



#define IRDA_POWERMODE_NORMAL
#define IRDA_POWERMODE_LOWPOWER
typedef enum
{
  HAL_UART_IRDA_POWER_MODE_NORMAL
  HAL_UART_IRDA_POWER_MODE_LOW
} hal_uart_irda_power_mode_t;

HAL IRDA enable/disable mode

HAL1

HAL2

#define IRDA_MODE_DISABLE
#define IRDA_MODE_ENABLE

Removed; IRDA mode is enabled internally in all cases within the function HAL_UART_IRDA_SetConfig().


HAL IRDA mode settings constants

HAL1

HAL2



#define IRDA_MODE_RX
#define IRDA_MODE_TX
#define IRDA_MODE_TX_RX
typedef enum
{
  HAL_UART_DIRECTION_RX,
  HAL_UART_DIRECTION_TX,
  HAL_UART_DIRECTION_TX_RX
} hal_uart_direction_t;

HAL IRDA one bit sample enable/disable constants

HAL1

HAL2



#define IRDA_ONE_BIT_SAMPLE_DISABLE
#define IRDA_ONE_BIT_SAMPLE_ENABLE
typedef enum
{
  HAL_UART_ONE_BIT_SAMPLE_DISABLE,
  HAL_UART_ONE_BIT_SAMPLE_ENABLE
} hal_uart_one_bit_sample_t;

HAL IRDA parity settings constants

HAL1

HAL2



#define IRDA_PARITY_NONE
#define IRDA_PARITY_EVEN
#define IRDA_PARITY_ODD
typedef enum
{
  HAL_UART_PARITY_NONE,
  HAL_UART_PARITY_EVEN,
  HAL_UART_PARITY_ODD
} hal_uart_parity_t;

HAL IRDA word length settings constants

HAL1

HAL2



#define IRDA_WORDLENGTH_7B
#define IRDA_WORDLENGTH_8B
#define IRDA_WORDLENGTH_9B
typedef enum
{
  HAL_UART_WORD_LENGTH_7_BIT,
  HAL_UART_WORD_LENGTH_8_BIT,
  HAL_UART_WORD_LENGTH_9_BIT
} hal_uart_word_length_t;

HAL IRDA prescaler division values constants

HAL1

HAL2



#define IRDA_PRESCALER_DIV1
#define IRDA_PRESCALER_DIV2
#define IRDA_PRESCALER_DIV4
#define IRDA_PRESCALER_DIV6
#define IRDA_PRESCALER_DIV8
#define IRDA_PRESCALER_DIV10
#define IRDA_PRESCALER_DIV12
#define IRDA_PRESCALER_DIV16
#define IRDA_PRESCALER_DIV32
#define IRDA_PRESCALER_DIV64
#define IRDA_PRESCALER_DIV128
#define IRDA_PRESCALER_DIV256
typedef enum
{
  HAL_UART_PRESCALER_DIV1,
  HAL_UART_PRESCALER_DIV2,
  HAL_UART_PRESCALER_DIV4,
  HAL_UART_PRESCALER_DIV6,
  HAL_UART_PRESCALER_DIV8,
  HAL_UART_PRESCALER_DIV10,
  HAL_UART_PRESCALER_DIV12,
  HAL_UART_PRESCALER_DIV16,
  HAL_UART_PRESCALER_DIV32,
  HAL_UART_PRESCALER_DIV64,
  HAL_UART_PRESCALER_DIV128,
  HAL_UART_PRESCALER_DIV256
} hal_uart_prescaler_t;

HAL IRDA clear register flags constants

HAL1

HAL2

In HAL1, the following definitions are utilized by the __HAL_IRDA_CLEAR_FLAG and __HAL_IRDA_CLEAR_IT macros.

#define IRDA_CLEAR_FEF
#define IRDA_CLEAR_IDLEF
#define IRDA_CLEAR_NEF
#define IRDA_CLEAR_OREF
#define IRDA_CLEAR_PEF
#define IRDA_CLEAR_TCF

Removed; use LL_USART_ClearFlag() instead with the appropriate parameters.

For more details refer to: General HAL IRDA clear flags.


HAL IRDA status flags constants

HAL1

HAL2

In HAL1, the following definitions are utilized by the __HAL_IRDA_GET_FLAG() macro.

#define IRDA_FLAG_ABRE
#define IRDA_FLAG_ABRF
#define IRDA_FLAG_BUSY
#define IRDA_FLAG_FE
#define IRDA_FLAG_IDLE
#define IRDA_FLAG_NE
#define IRDA_FLAG_ORE
#define IRDA_FLAG_PE
#define IRDA_FLAG_REACK
#define IRDA_FLAG_RXNE
#define IRDA_FLAG_TC
#define IRDA_FLAG_TEACK
#define IRDA_FLAG_TXE

Removed; use LL_USART_IsActiveFlag() instead with the appropriate parameters.

For more details HAL IRDA get flag/interrupt


HAL IRDA interrupt identifiers constants

HAL1

HAL2

In HAL1, the following definitions are utilized by the __HAL_IRDA_ENABLE_IT(), __HAL_IRDA_GET_IT_SOURCE() and __HAL_IRDA_GET_IT() macros.

#define IRDA_IT_CTS
#define IRDA_IT_ERR
#define IRDA_IT_FE
#define IRDA_IT_IDLE
#define IRDA_IT_LBD
#define IRDA_IT_MASK
#define IRDA_IT_NE
#define IRDA_IT_ORE
#define IRDA_IT_PE
#define IRDA_IT_RXNE
#define IRDA_IT_TC
#define IRDA_IT_TXE

Removed; use LL_USART_EnableIT_XXX(), LL_USART_IsEnabledIT_XXX() and LL_USART_IsActiveFlag() instead .


HAL IRDA data flush request constants

HAL1

HAL2



#define IRDA_RXDATA_FLUSH_REQUEST
#define IRDA_TXDATA_FLUSH_REQUEST
#define IRDA_AUTOBAUD_REQUEST
typedef enum
{
  HAL_UART_REQUEST_RX_DATA_FLUSH,
  HAL_UART_REQUEST_TX_DATA_FLUSH
  HAL_UART_REQUEST_AUTO_BAUD_RATE,
  HAL_UART_REQUEST_SEND_BREAK,
  HAL_UART_REQUEST_MUTE_MODE,
} hal_uart_request_t;

HAL IRDA DMA RX/TX enable/disable constants

HAL1

HAL2

#define IRDA_DMA_RX_DISABLE
#define IRDA_DMA_RX_ENABLE
#define IRDA_DMA_TX_DISABLE
#define IRDA_DMA_TX_ENABLE

Removed; In HAL2 these constants have been removed since they served only internal driver functions and had no effect on user-level operations.

HAL IRDA enable/disable state constants

HAL1

HAL2

#define IRDA_STATE_DISABLE
#define IRDA_STATE_ENABLE

Removed; In HAL2 these constants have been removed since they served only internal driver functions and had no effect on user-level operations.


HAL IRDA masks and positions constants

HAL1

HAL2

#define IRDA_CR_MASK
#define IRDA_CR_POS
#define IRDA_ISR_MASK
#define IRDA_ISR_POS

Removed; In HAL2 these constants have been removed since they served only internal driver functions and had no effect on user-level operations.